home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / syslib.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  5.3 KB  |  221 lines

  1. #include <minix/const.h>
  2. #include <minix/type.h>
  3. #include <minix/callnr.h>
  4. #include <minix/com.h>
  5. #include <errno.h>
  6. #ifdef __STDC__
  7. #include <sys/types.h>
  8. #include <unistd.h>
  9. #endif
  10.  
  11. #define OK 0
  12.  
  13. #define FS          FS_PROC_NR
  14. #define MM          MMPROCNR
  15.  
  16. extern message M;
  17.  
  18.  
  19. /*----------------------------------------------------------------------------
  20.             Messages to systask (special calls)
  21. ----------------------------------------------------------------------------*/
  22.  
  23. #ifdef ATARI_ST
  24. PUBLIC void sys_xit(parent, proc, basep, sizep)
  25. phys_clicks *basep, *sizep;
  26. #else
  27. PUBLIC sys_xit(parent, proc)
  28. #endif
  29. int parent;            /* parent of exiting proc. */
  30. int proc;            /* which proc has exited */
  31. {
  32. /* A proc has exited.  Tell the kernel. */
  33.  
  34.   callm1(SYSTASK, SYS_XIT, parent, proc, 0, NIL_PTR, NIL_PTR, NIL_PTR);
  35. #ifdef ATARI_ST
  36.   *basep = (phys_clicks)M.m1_i1;
  37.   *sizep = (phys_clicks)M.m1_i2;
  38. #endif
  39. }
  40.  
  41.  
  42. PUBLIC void sys_getsp(proc, newsp)
  43. int proc;            /* which proc has enabled signals */
  44. vir_bytes *newsp;        /* place to put sp read from kernel */
  45. {
  46. /* Ask the kernel what the sp is. */
  47.  
  48.  
  49.   callm1(SYSTASK, SYS_GETSP, proc, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
  50.   *newsp = (vir_bytes) M.STACK_PTR;
  51. }
  52.  
  53.  
  54. PUBLIC void sys_sig(proc, sig, sighandler)
  55. int proc;            /* which proc has exited */
  56. int sig;            /* signal number: 1 - 16 */
  57. int (*sighandler)();        /* pointer to signal handler in user space */
  58. {
  59. /* A proc has to be signaled.  Tell the kernel. */
  60.  
  61.   M.m6_i1 = proc;
  62.   M.m6_i2 = sig;
  63.   M.m6_f1 = sighandler;
  64.   callx(SYSTASK, SYS_SIG);
  65. }
  66.  
  67.  
  68. #ifdef ATARI_ST
  69. #ifdef __STDC__
  70. PUBLIC void sys_fork(int parent, int child, int pid, phys_clicks shadow)
  71. #else
  72. PUBLIC void sys_fork(parent, child, pid, shadow)
  73. #endif
  74. #ifdef ALCYON_C_BUG_FIXED
  75. phys_clicks shadow;        /* memory allocated for shadow */
  76. #endif
  77. #else
  78. PUBLIC sys_fork(parent, child, pid)
  79. #endif
  80. #ifndef __STDC__
  81. int parent;            /* proc doing the fork */
  82. int child;            /* which proc has been created by the fork */
  83. int pid;            /* process id assigned by MM */
  84. #endif
  85. {
  86. /* A proc has forked.  Tell the kernel. */
  87.  
  88. #ifdef ATARI_ST
  89.   callm1(SYSTASK, SYS_FORK, parent, child, pid, (char *)shadow, NIL_PTR, NIL_PTR);
  90. #else
  91.   callm1(SYSTASK, SYS_FORK, parent, child, pid, NIL_PTR, NIL_PTR, NIL_PTR);
  92. #endif
  93. }
  94.  
  95.  
  96. PUBLIC void sys_exec(proc, ptr, traced)
  97. int proc;            /* proc that did exec */
  98. _VOIDSTAR ptr;            /* new stack pointer */
  99. int traced;            /* is tracing enabled? */
  100. {
  101. /* A proc has exec'd.  Tell the kernel. */
  102.  
  103.   callm1(SYSTASK, SYS_EXEC, proc, traced, 0, ptr, NIL_PTR, NIL_PTR);
  104. }
  105.  
  106. PUBLIC void sys_newmap(proc, ptr)
  107. int proc;            /* proc whose map is to be changed */
  108. _VOIDSTAR ptr;            /* pointer to new map */
  109. {
  110. /* A proc has been assigned a new memory map.  Tell the kernel. */
  111.  
  112.  
  113.   callm1(SYSTASK, SYS_NEWMAP, proc, 0, 0, ptr, NIL_PTR, NIL_PTR);
  114. }
  115.  
  116. PUBLIC void sys_copy(mptr)
  117. message *mptr;            /* pointer to message */
  118. {
  119. /* A proc wants to use local copy. */
  120.  
  121.   /* Make this routine better.  Also check other guys' error handling -DEBUG */
  122.   mptr->m_type = SYS_COPY;
  123.   if (sendrec(SYSTASK, mptr) != OK) panic("sys_copy can't send", NO_NUM);
  124. }
  125.  
  126. PUBLIC void sys_times(proc, ptr)
  127. int proc;            /* proc whose times are needed */
  128. real_time ptr[4];            /* pointer to time buffer */
  129. {
  130. /* Fetch the accounting info for a proc. */
  131.  
  132.   callm1(SYSTASK, SYS_TIMES, proc, 0, 0, ptr, NIL_PTR, NIL_PTR);
  133.   ptr[0] = M.USER_TIME;
  134.   ptr[1] = M.SYSTEM_TIME;
  135.   ptr[2] = M.CHILD_UTIME;
  136.   ptr[3] = M.CHILD_STIME;
  137. }
  138.  
  139.  
  140.  
  141.  
  142.  
  143. PUBLIC void sys_abort()
  144. {
  145. /* Something awful has happened.  Abandon ship. */
  146.  
  147.   callm1(SYSTASK, SYS_ABORT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
  148. }
  149.  
  150. #ifdef ATARI_ST
  151. #ifdef __STDC__
  152. PUBLIC void sys_fresh(int proc, _VOIDSTAR ptr, phys_clicks dc,
  153.               phys_clicks *basep, phys_clicks *sizep)
  154. #else
  155. PUBLIC void sys_fresh(proc, ptr, dc, basep, sizep)
  156. int proc;            /* proc whose map is to be changed */
  157. _VOIDSTAR ptr;            /* pointer to new map */
  158. phys_clicks dc;            /* size of initialized data */
  159. phys_clicks *basep, *sizep;    /* base and size for free_mem() */
  160. #endif
  161. {
  162. /* Create a fresh process image for exec().  Tell the kernel. */
  163.  
  164.   callm1(SYSTASK, SYS_FRESH, proc, (int)dc, 0, ptr, NIL_PTR, NIL_PTR);
  165.   *basep = (phys_clicks)M.m1_i1;
  166.   *sizep = (phys_clicks)M.m1_i2;
  167. }
  168. #endif
  169.  
  170.  
  171. PUBLIC void sys_kill(proc, sig)
  172. int proc;            /* which proc has exited */
  173. int sig;            /* signal number: 1 - 16 */
  174. {
  175. /* A proc has to be signaled via MM.  Tell the kernel. */
  176.  
  177.   M.m6_i1 = proc;
  178.   M.m6_i2 = sig;
  179.   callx(SYSTASK, SYS_KILL);
  180. }
  181.  
  182. PUBLIC int sys_trace(req, procnr, addr, data_p)
  183. int req, procnr;
  184. long addr, *data_p;
  185. {
  186.   int r;
  187.  
  188.   M.m2_i1 = procnr;
  189.   M.m2_i2 = req;
  190.   M.m2_l1 = addr;
  191.   if (data_p) M.m2_l2 = *data_p;
  192.   r = callx(SYSTASK, SYS_TRACE);
  193.   if (data_p) *data_p = M.m2_l2;
  194.   return r;
  195. }
  196.  
  197. PUBLIC void sys_nice(proc, incr)
  198. int proc, incr;
  199. {
  200. /* A process wants to change its scheduling priority. Tell the kernel. */
  201.  
  202.   callm1(SYSTASK, SYS_NICE, proc, incr, 0, NIL_PTR, NIL_PTR, NIL_PTR);
  203. }
  204.  
  205.  
  206. PUBLIC  void tell_fs(what, p1, p2, p3)
  207. int what, p1, p2, p3;
  208. {
  209. /* This routine is only used by MM to inform FS of certain events:
  210.  *      tell_fs(CHDIR, slot, dir, 0)
  211.  *      tell_fs(EXIT, proc, 0, 0)
  212.  *      tell_fs(FORK, parent, child, pid)
  213.  *      tell_fs(SETGID, proc, realgid, effgid)
  214.  *      tell_fs(SETUID, proc, realuid, effuid)
  215.  *      tell_fs(SYNC, 0, 0, 0)
  216.  *      tell_fs(UNPAUSE, proc, signr, 0)
  217.  *      tell_fs(SETPGRP, proc, 0, 0)
  218.  */
  219.   callm1(FS, what, p1, p2, p3, NIL_PTR, NIL_PTR, NIL_PTR);
  220. }
  221.